package concurrent;

/**
 * @Classname MultipyThread
 * @Description TODO
 * @Date 2021/11/25 17:45
 * @Created by ASUS
 */
public class MultipyThread {
    static class LockItem {
        public int val;
    }

    static class MyThread implements Runnable {
        @Override
        public void run() {
            System.out.println("Runnable run function...");
            try {
                synchronized (lockItem) {

                    lockItem.wait();
                }
                System.out.println("Called wait func...");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    static class InterruptThread implements Runnable {
        @Override
        public void run() {
            synchronized (lockItem) {
                lockItem.notify();
                thread1.interrupt();
                Thread.interrupted();
                System.out.println("notify thread 1");
            }
        }
    }

    public static LockItem lockItem = new LockItem();
    static Thread thread1 = new Thread(new MyThread());
    static Thread thread2 = new Thread(new InterruptThread());

    public static void main(String[] args) throws InterruptedException {
        thread1.start();
        Thread.sleep(5);
        thread2.start();
    }
}
